﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Practices.Unity;
using Praxis.Entities;
using Praxis.BusinessLogic;

namespace Praxis.UI
{
    public partial class FrmCliente : Form
    {
        [Dependency]
        public IClienteBL clienteBL { get; set; }

        public FrmCliente()
        {
            InitializeComponent();
            this.BuildUp();
        }

        private void FrmCliente_Load(object sender, EventArgs e)
        {
            cLIENTEBindingSource.DataSource = clienteBL.GetAllClientes();
        }

        private void BtnNuevo_Click(object sender, EventArgs e)
        {
            FrmMttoCliente frmmttocliente = new FrmMttoCliente();
            frmmttocliente.Nuevo();
            frmmttocliente.ShowDialog();
            //this.Hide();
        }

        private void BtnEditar_Click(object sender, EventArgs e)
        {
            CLIENTE currentCliente = cLIENTEBindingSource.Current as CLIENTE;
            if (currentCliente != null)
            {
                FrmMttoCliente frmmttocliente = new FrmMttoCliente();
                frmmttocliente.CurrentCliente = currentCliente;
                frmmttocliente.Editar();
                frmmttocliente.ShowDialog();
            }
            else
            {
                MessageBox.Show("Mensaje", "Seleccione un Item", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
         
        }

        private void BtnBuscar_Click(object sender, EventArgs e)
        {
            cLIENTEBindingSource.DataSource = clienteBL.GetFromClienteByDescripcion(TxtDescripcion.Text);
        
        }
    }
}
